#include <stdio.h>
#include <errno.h>
#include <dirent.h>

int main(int argc, const char **argv) {
    DIR *dp = opendir(".");
    if (!dp) {
        perror("opendir error");
        return -errno;
    }

    struct dirent *dirp = nullptr;
    while((dirp = readdir(dp))) {
        printf("%d %d %s\n", dirp->d_reclen, dirp->d_type, dirp->d_name);

        if (dirp->d_type == DT_REG) printf("regular file\n");
        if (dirp->d_type == DT_DIR) printf("directory\n");
    }
    return 0;
}
